package Day16.Top02;

import java.util.Scanner;

public class Player {
    private int levelNo;//玩家当前级别号
    private int currScore;//玩家当前级别积分
    private long startTime;//当前级别开始时间
    private int elapsedTime;//当前级别已用时间
    Game game=new Game();

    public Player(){
        this.setLevelNo(1);
    }
    public int getLevelNo() {
        return levelNo;
    }

    public void setLevelNo(int levelNo) {
        this.levelNo = levelNo;
    }

    public int getCurrScore() {
        return currScore;
    }

    public void setCurrScore(int currScore) {
        this.currScore = currScore;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public int getElapsedTime() {
        return elapsedTime;
    }

    public void setElapsedTime(int elapsedTime) {
        this.elapsedTime = elapsedTime;
    }


    public void printResult(){
        while(true){
             Scanner sc=new Scanner(System.in);
        String in = game.printStr(this.levelNo);
        System.out.println("请输入:");
        setStartTime( System.currentTimeMillis());
        String out = sc.next();
        long endtTime = System.currentTimeMillis();
        this.elapsedTime= (int)((endtTime- startTime)/1000);
        if (out.equals(in)){
            long cuurrTime=System.currentTimeMillis();
            if ((cuurrTime-getStartTime())/1000>LevelParam.levels[getLevelNo() - 1].getTimeLimit()){
                System.out.println("你输入太慢了，已经超时，退出！");
                System.exit(1);
            }else {
                setCurrScore(getCurrScore()+ LevelParam.levels[getLevelNo() - 1].getPerScore());
                System.out.println("输入正确,目前积分为"+getCurrScore()+"分\t等级为"+getLevelNo()+"\t用时"+(cuurrTime-getStartTime())/1000+"秒");
                if (getCurrScore()==2){
                        setCurrScore(0);
                        levelNo++;
                    }
                if (getLevelNo()==6){
                    System.out.println("恭喜您,闯关成功");
                    System.exit(0);
                }
            }
        }else {
            System.out.println("闯关失败");
            System.exit(1);
        }
    
        }
    }
}
